/*This is the one-and-only main method for my final project. Have fun!*/
import java.util.*;
public class FinalProject {

	public static void main (String [] args)
	{
		
		Scanner sc = new Scanner (System.in);
		String name;
		Rooms rooms = new Rooms();
		BossBattle boss = new BossBattle();
		Inventory inventory = new Inventory();
		
		int health=100;
		int numOfAttacksFrank=0;/*used to count the number of times a player attacks Frank*/
		int numOfAttacksBilly=0;/*same as above, except for Billy*/
		int roomNumber=85;/*keeps track of the room number the user is currently in*/
		int choice = 0;/*(used for the switch-case statements) it is how the user will be able
		 			   to choose from the list of options presented by the Rooms class*/
		
		/*The following booleans are to prevent silly errors like having Frank appear twice,
		  and to warn players in situations such as "I wouldn't hit him again".*/
		boolean caseOneRoom76=false;
		boolean caseOneRoom85=false;
		boolean caseTwoRoom76=false;
		boolean frankAppeared=false;
		boolean billyAppeared=false;
		
		/*The beginning!*/
		System.out.print("Welcome to Island Escape, a text-based adventure." +
						 "\nWhat is your name? ");
		name=sc.nextLine();
		
		/*Is this a cheat code? I think so!*/
		if (name.equals("Billy A. Haupt")){
			System.out.println("Congratulations, you're starting with all items unlocked!");
			inventory.Gameboy=true;
			inventory.GoldenWood=true;
			inventory.GoldenSail=true;
			inventory.PlasticShovel=true;
			inventory.Lantern=true;
		}
		System.out.println("\n"+ name +", "+ name +" wake up!");
		System.out.println("You were awoken by an ugly, older looking man, with a slightly large gut. He sort of resembled" +
						   "\na cross between Mr.D'melick and a man hit by a bus. He wasn't looking in such good shape, and.\n" +
						   "is missing his gameboy. You're lying in a bed of sand, on a beach somewhere unknown, with a book titled\n" +
						   "'Rule book' lying next to you.");
			
		
		
		while(true){	
		while(roomNumber==85){
			System.out.println(rooms.RoomEightyFive());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();

			switch (choice){
			case 1:
				if(caseOneRoom85==true){
					System.out.println("You might want to stop hitting him...");
					health= health-10;
					System.out.println("You're health remaining: " + (health) + "HP");
					while(health==0){
						System.out.println("You have died. Game over");
						sc.nextLine();
					}
				}
				else{
				System.out.println("Little did you know that this older looking man was actually a black belt in Karate.\n" +
								   "You were drop-kicked in the face, at a loss of 10 Hit Points.");
				health= health-10;
				System.out.println("You're health remaining: " + (health) + "HP");
				caseOneRoom85=true;
				while(health==0){
					System.out.println("You have died. Game over");
					sc.nextLine();
				}
				}
				break;
			case 2:
				System.out.println("That was a good decision. Here's a list of rules:\n" +
								   "rule 1: When choosing what to do, please only enter the number of the response.\n" +
								   "rule 2: Your beginning health is 100 HP, but you have unlimited potions. Real men wont use them.\n" +
								   "rule 3: If you run out of HP you die. It kind of makes sense...\n" +
								   "The rest of the book's pages were ripped out...");
				break;
			case 3:
				roomNumber=84;
				break;
			case 4:
				roomNumber=86;
				break;
			case 5:
				if (inventory.Gameboy==true)
				{
					System.out.println("Wahoo it's my gameboy!  Now, I must help you in return. In order to get off of this\n" +
									   "island you must collect both the golden wood and the golden sail to create a sailboat.\n" +
									   "Once obtained, you can go to area 86 and construct this boat to escape this island.");
				}
				else
				{
					System.out.println("If you do not possess a gameboy, how can you give him one?");
				}
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
	
		
		
		while(roomNumber==84)
		{
			System.out.println(rooms.RoomEightyFour());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch (choice){
			case 1:
				System.out.println("You feel the sand beneath your toes. Looking out at the ocean, you contemplate\n" +
						"swimming away, but then decide the idea is as dumb as making your bed in the morning (you\njust" +
						" sleep in it again later). Also, you notice lying to your right is an old gameboy." +
						"");
				break;
			case 2:
				System.out.println("Wow you've picked up an old gameboy with sand in it! Why would anybody want this?");
				inventory.Gameboy=true;
				break;
			case 3:
				roomNumber=85;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}	
	
		
		
		while(roomNumber==86){
			System.out.println(rooms.RoomEightySix());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch (choice){
			case 1:
				if (inventory.GoldenSail==true){
					if (inventory.GoldenWood=true){
						System.out.println("Congratulations, you have gotten off of the island!!!!  Unfortunately,\n" +
								"seconds after sailing away the ship hit a rock and a huge hole formed in the bottom\n" +
								"of the boat.  Thats just unfortunate...\n\n\n" +
								"Credits:\n" +
								"Coder: Gary W. Horan III\n" +
								"Monsters: Frank Mischin and Billy A. Haupt*\n" +
								"Teacher who gave me this assignment: Mr.B\n\n" +
								"By the way, theres an items unlock password at the beginning, and a hint at it is in\n" +
								"the credits.");
						sc.nextLine();
						sc.nextLine();
					}
				}
				else
				{
					System.out.println("You probably need tools and materials to build a sailboat\n" +
									   "before you build one.  You would know what to get if you\n" +
									   "help out that poor guy.");
				}
				break;
			case 2:
				roomNumber=76;
				break;
			case 3:
				roomNumber=85;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
				
			}
		}	
	
		
		
		while(roomNumber==76){
			System.out.println(rooms.RoomSeventySix());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch (choice){
			case 1:
			caseOneRoom76=true;
				System.out.println("Wrong! The man strikes you down at a loss of 50 HP.  Ouch!");
				health= health-50;
				System.out.println("You're health remaining: " + (health) + "HP\n");
				while(health==0){
					System.out.println("You have died. Game over");
					sc.nextLine();
				}
				break;
			case 2:
				if (caseOneRoom76==true){
					System.out.println("Nice try fighting me buddy, you're lucky I'm still talking to you.");
				}
				if (caseTwoRoom76==true){
					System.out.println("I've already given you the plastic shovel, what else could you want?");
				}
				else{
				System.out.println("I am the mayor of this here town.  Most of these people like trading,\n" +
						"and I can guarantee you that if you trade with them, you will be a very prosperous man.\n" +
						"Here, an item for your travels:\n");
				System.out.println(name+ " received a plastic sandbox shovel with a razor-sharp tip!  Maybe you\n" +
						"can trade this for something better...\n");
				caseTwoRoom76=true;
				}
				break;
			case 3:
				roomNumber=75;
				break;
			case 4:
				roomNumber=66;
				break;
			case 5:
				roomNumber=86;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
		
		
		
		while(roomNumber==75){
				System.out.println(rooms.RoomSeventyFive());
				while(!sc.hasNextInt())
				{
					sc.nextLine();
					System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
				}
				choice = sc.nextInt();
				switch (choice){
				case 1:
					if (inventory.Lantern(false)){
						System.out.println("The farmer has decided he no longer wants to talk to you. Why does he keep beaconing you over?\n" +
										   "What a weirdo...");
					}
					else if (inventory.PlasticShovel=true){
					System.out.println("Thank goodness you have that plastic shovel, my daughter was looking for one!\n" +
									   "I will gladly trade you this lantern for your plastic shovel.");
					System.out.println("You've recieved a lantern!");
					inventory.Lantern(true);
					}
					else{
						System.out.println("Once you have a plastic shovel then we'll talk...");
					}
					break;
				case 2:
					roomNumber=65;
					break;
				case 3:
					roomNumber=76;
					break;
				case 4:
					roomNumber=74;
					break;
				default:
					System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
				}
			}
		while(roomNumber==74){
			System.out.println(rooms.RoomSeventyFour());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=73;
				break;
			case 2:
				roomNumber=75;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}

		
		while(roomNumber==73){
			if (inventory.Lantern==true){
				System.out.println("There isn't all that much to see here.  Just a couple of rocks on the ground...");
				}
			System.out.println(rooms.RoomSeventyThree());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice=sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=63;
				break;
			case 2:
				roomNumber=72;
				break;
			case 3:
				roomNumber=74;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
				}
			}
		
		
		
		
		while(roomNumber==63){
			if (inventory.Lantern==false){
				System.out.println("You were killed by a foe you were unable to see.  Maybe you should have brought\n" +
								   "a lantern.");
				health=health-100;
				while(health==0){
					System.out.println("You have died. Game over");
					sc.nextLine();
					}
			}
				else if(frankAppeared=true){
					roomNumber=1;
					break;
				}
					System.out.println(rooms.RoomSixtyThree());
					switch(choice){
					case 1:
						roomNumber=73;
						break;
					case 2:
						roomNumber=2;
						break;
					}
					
				}
		
		
		
		while(roomNumber==1){
			System.out.println("A wild Frank appeared!");
			System.out.println(rooms.MonsterRoom());
			frankAppeared=true;
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice=sc.nextInt();
			switch(choice){
			case 1:
				System.out.println("You punched Frank for a hit of 20HP!");
				numOfAttacksFrank++;
				System.out.println("Frank's health:" + (boss.frank-(20*numOfAttacksFrank)));
				if(boss.frank-(20*numOfAttacksFrank)<0){
					System.out.println("You have defeated Frank!");
					roomNumber=63;
					break;
				}
				System.out.println("He returned with a his super-intelligent-brain attack! You lost 5HP");
				health=health-5;
				System.out.println("You're health remaining: " + health);
				while(health==0){
					System.out.println("You have died. Game over");
					sc.nextLine();	
				}
				break;
			case 2:
				System.out.println("You're superb defense caused you to lose no HP from Frank's attack!");
				break;
			case 3:
				System.out.println("You have healed 20 HP!");
				break;
			case 4:
				System.out.println("Don't back down!");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");	
				break;
			}
		}
	
		
		
		while(roomNumber==72){
			if (inventory.Lantern==true)
				System.out.println("There isn't all that much to see here.  Just a couple of rocks on the ground...");
			System.out.println(rooms.RoomSeventyTwo());
			while(!sc.hasNextInt()){
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=2;
				break;
			case 2:
				roomNumber=73;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		
		while(roomNumber==2)
			if (billyAppeared=true){
				roomNumber=62;
				break;
				}
			else if(inventory.Lantern==true){
				System.out.println("Boss Billy-Kong appeared!");
				billyAppeared=true;
				rooms.MonsterRoom();
				switch(choice){
				case 1:
					System.out.println("Before you could attack, Billy through pi(3.1415926...) at you for 15 HP.");
					health=health-15;
					System.out.println("You're health remaining: " + (health) + "HP");
					while(health==0){
						System.out.println("You have died. Game over");
						sc.nextLine();
					}
					System.out.println("You attack Billy with a backhand to the face, only to make a hit worth 25HP.");
					System.out.println("Billy's health:" + (boss.billy-25*numOfAttacksBilly));
					if(boss.billy<0){
						System.out.println("You have defeated Billy!");
						roomNumber=62;
						break;
					}
					break;
				case 2:
					System.out.println("You have successfully defended, but Billy's attack still hurt you 5 HP");
					health=health-5;
					System.out.println("You're health remaining: " + (health) + "HP");
					while(health==0){
						System.out.println("You have died. Game over");
						sc.nextLine();
					}
					break;
				case 3:
					System.out.println("You healed 20HP!");
					health=health+20;
					case 4:
						System.out.println("Don't back down!");
						break;
					default:
						System.out.println("Good job idiot, you didn't enter a valid response. Try again.");	
					}
				}
	
		while (roomNumber==62){
			System.out.println(rooms.RoomSixtyTwo());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=72;
				break;
			case 2:
				roomNumber=63;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
			
			
			
		while (roomNumber==65){
			System.out.println("Welcome to Help Me!");
			System.out.println(rooms.RoomSixtyFive());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch(choice){
			case 1:
				System.out.println("A golden sail and golden wood will be needed to get off of this island.");
				break;
			case 2:
				System.out.println("If I were to guess, I'd say a dark cave would be a good place to look.\n" +
						"Why a dark cave?  I don't know, why not ask Gary the creator?");
				break;
			case 3:
				System.out.println("Bye!");
				roomNumber=75;
				break;	
			case 4:
				System.out.println("Bye!");
				roomNumber=66;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
		while(roomNumber==66){
			System.out.println(rooms.RoomSixtySix());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
			choice = sc.nextInt();
			switch(choice){
			case 1:
				System.out.println("I only let those in those who possess the golden sail to these dangerous woods");
				break;
			case 2:
				if(inventory.GoldenSail==false)
				System.out.println("None shall pass!");
				else
					roomNumber=56;
				break;
			case 3:
				roomNumber=65;
				break;
			case 4:
				roomNumber=76;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
		
		
		while(roomNumber==56){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=46;
				break;
			case 2:
				roomNumber=66;
				break;
			case 3:
				System.out.println("A line of trees blocks that direction...");
				break;
			case 4:
				roomNumber=57;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again.");
			}
		}
		
		
		while(roomNumber==57){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=47;
				break;
			case 2:
				System.out.println("A line of trees blocks this path...");
				break;
			case 3:
				roomNumber=56;
				break;
			case 4:
				System.out.println("A line of trees blocks this path...");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		while(roomNumber==45){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=35;
				break;
			case 2:
				System.out.println("A line of trees blocks this path...");
				break;
			case 3:
				roomNumber=46;
				break;
			case 4:
				System.out.println("A line of trees blocks this path...");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		while(roomNumber==46){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=36;
				break;
			case 2:
				roomNumber=56;
				break;
			case 3:
				roomNumber=45;
				break;
			case 4:
				roomNumber=47;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		while(roomNumber==47){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=37;
				break;
			case 2:
				roomNumber=57;
				break;
			case 3:
				System.out.println("A line of trees blocks this path...");
				break;
			case 4:
				roomNumber=46;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");		
			}
		}

		while(roomNumber==35){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				System.out.println("A line of trees blocks this path...");
				break;
			case 2:
				roomNumber=45;
				break;
			case 3:
				roomNumber=36;
				break;
			case 4:
				System.out.println("A line of trees blocks this path...");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}

		while(roomNumber==36){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=26;
				break;
			case 2:
				roomNumber=46;
				break;
			case 3:
				roomNumber=37;
				break;
			case 4:
				roomNumber=35;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}

		while(roomNumber==37){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch (choice){
			case 1:
				roomNumber=27;
				break;
			case 2:
				roomNumber=47;
				break;
			case 3:
				System.out.println("A line of trees blocks this path...");
				break;
			case 4:
				roomNumber=36;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}

		while(roomNumber==26){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				System.out.println("A line of trees blocks this path...");
				break;
			case 2:
				roomNumber=36;
				break;
			case 3:
				roomNumber=27;
				break;
			case 4:
				System.out.println("A line of trees blocks this path...");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		while(roomNumber==27){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=17;
				break;
			case 2:
				roomNumber=37;
				break;
			case 3:
				System.out.println("A line of trees blocks this path...");
				break;
			case 4:
				roomNumber=26;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		while(roomNumber==17){
			System.out.println(rooms.MazeOfConfusion());
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice= sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=7;
				break;
			case 2:
				roomNumber=27;
				break;
			case 3:
				System.out.println("A line of trees blocks this path...");
				break;
			case 4:
				System.out.println("A line of trees blocks this path...");
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		while(roomNumber==7){
			System.out.println(rooms.RoomSeven());
			inventory.GoldenWood(true);
			while(!sc.hasNextInt())
			{
				sc.nextLine();
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
			choice=sc.nextInt();
			switch(choice){
			case 1:
				roomNumber=17;
				break;
			default:
				System.out.println("Good job idiot, you didn't enter a valid response. Try again");
			}
		}
		
		}
	}
}